﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class ReVoteDAL : SyncBase<Model.ReVote>
    {
        static ReVoteDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReVoteDAL.addSQL = @"insert into TempReVote(
TeacherID,LessionID,VoteBatch,StartTime,StartPiont,EndTime,EndPiont,IsEnd)
 values (
@TeacherID,@LessionID,@VoteBatch,@StartTime,@StartPiont,@EndTime,@EndPiont,@IsEnd)";
            ReVoteDAL.tbName = "TempReVote";
            ReVoteDAL.remoteUrl = "/Ayyfford/AddReVote";
            ReVoteDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0}, {1}, {2}, {3}, {4}, {5}, {6},{7}),",
                            t.TeacherID.NullNumber(), t.LessionID.NullNumber(), t.VoteBatch.NullNumber(), t.StartTime.NullDate(), t.StartPiont.NullNumber(), t.EndTime.NullDate(), t.EndPiont.NullNumber(), t.IsEnd ? 1 : 0);
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReVote t)
        {
            SyncBase<Model.ReVote>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReVote>.AsyncData();
        }
    }
}
